package cn.leida;

import cn.leida.base.config.LeidaConfig;
import cn.leida.ruoyi.common.annotation.DataSource;
import cn.leida.ruoyi.common.config.AppConfig;
import cn.leida.ruoyi.framework.aspectj.DataSourceAspect;
import cn.leida.ruoyi.framework.config.CaptchaConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.web.server.ConfigurableWebServerFactory;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpStatus;
import org.springframework.scheduling.annotation.EnableScheduling;

/**
 * @author lei
 * @create 2025-03-11 18:38
 */
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@EnableScheduling // 定时任务
public class AdminServerDevApplication {

    @Bean
    public WebServerFactoryCustomizer<ConfigurableWebServerFactory> webServerFactoryCustomizer() {
        return factory -> {
            ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/index.html");
            factory.addErrorPages(error404Page);
        };
    }

    public static void main(String[] args) {
        AppConfig.changeDB(false);
        AppConfig.showDoc(true);
        LeidaConfig.changDev(false);
        // 下载行为日志
        LeidaConfig.downAction(false);
        // 初始化浏览器驱动
        SpringApplication.run(AdminServerDevApplication.class, args);

        System.out.println("修改配置文件: SecurityConfig.class");

        System.out.println("=============修改包名=================");
        System.out.println("1.自动完成" + CaptchaConfig.class);
        System.out.println("2.必须手动" + DataSourceAspect.class + "=====" + DataSource.class.getName());

        System.out.println("============server===success=============");
        System.out.println("============server===success=============");
        System.out.println("============server===success=============");



    }
}
